package com.study.d028shape3d;

import javafx.application.Application;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Box;
import javafx.scene.shape.Cylinder;
import javafx.scene.shape.Shape3D;
import javafx.scene.shape.Sphere;
import javafx.stage.Stage;

/**
*@description
*@author xtayhame
*date 2020年3月21日
*version
*since v1.0
*/
public class PhongMaterialMain extends Application{
	public static void main(String[] args) {
		launch(args);
	}
	@Override
	public void start(Stage stage) throws Exception {
		AnchorPane anchorPane = new AnchorPane();
		HBox box = new HBox(40);

		Box b1  = new Box(100, 100, 100);
		Sphere b2 = new Sphere(50, 200);
		Cylinder b3 = new Cylinder(50, 150);
		box.getChildren().addAll(b1,b2,b3);
		anchorPane.getChildren().add(box);
		Scene scene = new Scene(anchorPane, 600, 400, true);
		//添加摄像机
		scene.setCamera(new PerspectiveCamera());
		stage.setScene(scene);
		stage.centerOnScreen();
		stage.show();

		for(int i=0;i<box.getChildren().size();i++){
			Shape3D s=(Shape3D)box.getChildren().get(i);
			PhongMaterial pm = new PhongMaterial();
			pm.setDiffuseColor(Color.valueOf("#BF3EFF"));
			pm.setSpecularPower(1);
			s.setMaterial(pm);
		}

	}
}
